<?php

/*
 * CopyRight  : (C)2012-2099 HaoTeam Inc.
 * Document   : WechatAppValidate.php
 * Created on : 2021-2-4 16:40:39
 * Author     : Tiger <1192851302@qq.com>
 * Description: This is NOT a freeware, use is subject to license terms.
 *              这即使是一个免费软件,使用时也请遵守许可证条款,得到当时人书面许可.
 *              未经书面许可,不得翻版,翻版必究;版权归属 HaoTeam Inc;
 */

namespace haoteam\http\validates;

use think\Validate;

/**
 * 微信小程序验证器
 * Class WechatAppValidate
 * Tiger <1192851302@qq.com> 2021-2-4 16:40:39
 */
class WechatAppValidate extends Validate {

    protected $rule = [
        'id' => 'require|number',
        'name' => 'require|chsAlphaNum|max:16',
        'appid' => 'require|alphaDash|max:32',
        'appsecret' => 'require|alphaDash|max:32',
        'origin_id' => 'alphaDash|max:32',
        'field' => 'require',
        'value' => 'require'
    ];
    protected $message = [
        'id.require' => 'ID不能为空',
        'id.number' => 'ID格式不对',
        'name.require' => '名称不能为空',
        'name.chsAlphaNum' => '名称只能是汉字、字母和数字',
        'name.max' => '名称最多8个字',
        'appid.require' => 'appid 不能为空',
        'appid.alphaDash' => 'appid 只能是字母和数字，下划线及破折号',
        'appid.max' => 'appid 最多32个字',
        'appsecret.require' => 'appsecret 不能为空',
        'appsecret.alphaDash' => 'appsecret 只能是字母和数字，下划线及破折号',
        'appsecret.max' => 'appsecret 最多32个字',
        'origin_id.alphaDash' => '原始ID 只能是字母和数字，下划线及破折号',
        'origin_id.max' => '原始ID 最多32个字',
    ];
    protected $scene = [
        'create' => ['name', 'appid', 'appsecret', 'origin_id'],
        'update' => ['id', 'name', 'appid', 'appsecret', 'origin_id'],
        'delete' => ['id']
    ];

}
